﻿using System.Data;
namespace Codemonk.Common.Data
{
    /// <summary>
    /// DbCommand创建者接口
    /// 为庞大的DataAccessor分出可细化的DbCommand创建者
    /// </summary>
    public interface IDbCommandCreater
    {
        /// <summary>
        /// 创建DbCommandBuilder的无参数方法
        /// </summary>
        /// <returns>DbCommandBuilder</returns>
        System.Data.Common.DbCommandBuilder CreateCommandBuilder();
        /// <summary>
        /// 创建sql命令
        /// </summary>
        /// <returns>全新的命令</returns>
        IDbCommand CreateCommand();
        /// <summary>
        /// 创建sql命令
        /// </summary>
        /// <param name="connection">连接</param>
        /// <param name="cmdtext">sql</param>
        /// <param name="paras">参数数组</param>
        /// <returns>全新的命令</returns>
        IDbCommand CreateCommand(IDbConnection connection, string cmdtext, params IDataParameter[] paras);
        /// <summary>
        /// 创建sql命令
        /// </summary>
        /// <param name="connection">连接</param>
        /// <param name="cmdtext">sql</param>
        /// <param name="builder">参数数组</param>
        /// <returns>全新的命令</returns>
        IDbCommand CreateCommand(IDbConnection connection, string cmdtext, DbParameterBuilder builder);

        IDbCommand CreateCommand<T>(IDbConnection connection, string cmdtext, DbParameterBuilder<T> builder) where T : IDataParameter, new();
        /// <summary>
        /// 创建sql命令
        /// </summary>
        /// <param name="connection">连接</param>
        /// <param name="cmdtext">sql或存储过程</param>
        /// <param name="cmdtype">命令类型</param>
        /// <param name="tran">使用的事物</param>
        /// <param name="paras">参数构建者</param>
        /// <returns>全新的命令</returns>
        IDbCommand CreateCommand(IDbConnection connection, string cmdtext, CommandType cmdtype = CommandType.Text, IDbTransaction tran = null, params IDataParameter[] paras);
        /// <summary>
        /// 创建sql命令
        /// </summary>
        /// <param name="connection">连接</param>
        /// <param name="cmdtext">sql或存储过程</param>
        /// <param name="cmdtype">命令类型</param>
        /// <param name="tran">使用的事物</param>
        /// <param name="builder">参数构建者</param>
        /// <returns>全新的命令</returns>
        IDbCommand CreateCommand(IDbConnection connection, string cmdtext, DbParameterBuilder builder, CommandType cmdtype = CommandType.Text, IDbTransaction tran = null);

        IDbCommand CreateCommand<T>(IDbConnection connection, string cmdtext, DbParameterBuilder<T> builder, CommandType cmdtype = CommandType.Text, IDbTransaction tran = null) where T : IDataParameter, new();


        /// <summary>
        /// 创建sql命令
        /// </summary>
        /// <param name="cmdtext">sql</param>
        /// <param name="paras">参数数组</param>
        /// <returns>全新的命令</returns>
        IDbCommand CreateCommand(string cmdtext, params IDataParameter[] paras);
        /// <summary>
        /// 创建sql命令
        /// </summary>
        /// <param name="cmdtext">sql</param>
        /// <param name="builder">参数数组</param>
        /// <returns>全新的命令</returns>
        IDbCommand CreateCommand(string cmdtext, DbParameterBuilder builder);

        IDbCommand CreateCommand<T>(string cmdtext, DbParameterBuilder<T> builder) where T : IDataParameter, new();

        /// <summary>
        /// 创建sql命令
        /// </summary>
        /// <param name="cmdtext">sql或存储过程</param>
        /// <param name="cmdtype">命令类型</param>
        /// <param name="tran">使用的事物</param>
        /// <param name="paras">参数构建者</param>
        /// <returns>全新的命令</returns>
        IDbCommand CreateCommand(string cmdtext, CommandType cmdtype = CommandType.Text, IDbTransaction tran = null, params IDataParameter[] paras);
        /// <summary>
        /// 创建sql命令
        /// </summary>
        /// <param name="cmdtext">sql或存储过程</param>
        /// <param name="cmdtype">命令类型</param>
        /// <param name="tran">使用的事物</param>
        /// <param name="builder">参数构建者</param>
        /// <returns>全新的命令</returns>
        IDbCommand CreateCommand(string cmdtext, DbParameterBuilder builder, CommandType cmdtype = CommandType.Text, IDbTransaction tran = null);

        IDbCommand CreateCommand<T>(string cmdtext, DbParameterBuilder<T> builder, CommandType cmdtype = CommandType.Text, IDbTransaction tran = null) where T : IDataParameter, new();

    }
}
